import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './styles/global.css'
import ElementUI from 'element-ui'
import Bread from './components/Bread.vue'
import 'element-ui/lib/theme-chalk/index.css'

// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入富文本编辑器样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 全局注册富文本编辑器组件
Vue.use(VueQuillEditor)

Vue.config.productionTip = false

Vue.use(ElementUI)
Vue.component('Bread', Bread)

// {{ date | dateFormat('yyyy-mm-dd') }} 不填默认 yyyy-mm-dd hh-mm-ss
// 过滤器， 进行时间的格式化
Vue.filter('dateFormat', function (dateStr, pattern = '') {
  const dt = new Date(dateStr)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1).toString().padStart(2, '0')
  const d = dt.getDate().toString().padStart(2, '0')
  pattern.toLowerCase() // 传入参数转成小写
  if (pattern.toLowerCase() === 'yyyy-mm-dd') {
    return `${y}-${m}-${d}`
  } else {
    const hh = dt.getHours().toString().padStart(2, '0')
    const mm = dt.getMinutes().toString().padStart(2, '0')
    const ss = dt.getSeconds().toString().padStart(2, '0')
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
